numbers=input()
chislo=""
d=0
factor_access=0
jaja=numbers.split()
if len(jaja)!=3:
    print("Wrong input")
else:
    for k in range(len(jaja)):
        if jaja[k]=="nine" or jaja[k]=="eight" or jaja[k]=="seven" or jaja[k]=="six" or jaja[k]=="five" or jaja[k]=="four" or jaja[k]=="three" or jaja[k]=="two" or jaja[k]=="one" or jaja[k]=="zero":
                if jaja[k]=="nine":
                    chislo+="9"
                elif jaja[k]=="eight":
                    chislo+="8"
                elif jaja[k]=="seven":
                    chislo+="7"
                elif jaja[k]=="six":
                    chislo+="6"
                elif jaja[k]=="five":
                    chislo+="5"
                elif jaja[k]=="four":
                    chislo+="4"
                elif jaja[k]=="three":
                    chislo+="3"
                elif jaja[k]=="two":
                    chislo+="2"
                elif jaja[k]=="one":
                    chislo+="1"
                elif jaja[k]=="zero":
                    chislo+="0"
        else:
            factor_access=1
up=0
um=0
if factor_access==0:
    lukp=int(chislo)-1
    lukm=int(chislo)+1
    while d!=2:
        lukp += 1
        d=0
        for jake in range(1,lukp+1):
            if lukp%jake==0:
                d+=1
        up+=1
    d=0
    while d != 2:
        lukm -= 1
        d = 0
        for joke in range(1, lukm + 1):
            if lukm % joke == 0:
                d += 1
        um += 1
if factor_access==1:
    print("Wrong input")
else:
    if um>up:
        print(lukp)
    elif um<up:
        print(lukm)
    elif um==up:
        print(lukp) 